﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TSOL.FastSPWeb.ValueObjects;
using Microsoft.SharePoint;

namespace TSOL.FastSPWeb.Core
{
    internal class FastSPListsFactory
    {
        public static void BuildCollection(SPWeb Web, SPUserToken CurrentUserToken, int HashKey, SPListsCacheCollection SPListsCacheCollectionObject)
        {
            lock (SPListsCacheCollectionObject)
            {
                for (int ix = 0; ix < 1; ix++)
                {
                    SPListsCacheEntity Entity = new SPListsCacheEntity();
                    Entity.UserToken = CurrentUserToken;
                    Entity.Free = true;
                    foreach (SPList _list in Web.Lists) { 
                        SPViewCollection _views = _list.Views;
                    }

                    Entity.Lists = Web.Lists;
                    SPListsCacheCollectionObject.Add(Entity);
                }
            }

            lock (FastSPWebThreadWorkerQueue.GlobalSPWebThreadWorkerQueue.ListsCacheDictionary)
            {
                SPListsCacheCollection tempSPListCacheCollection = null;
                if (!FastSPWebThreadWorkerQueue.GlobalSPWebThreadWorkerQueue.ListsCacheDictionary.TryGetValue(HashKey, out tempSPListCacheCollection))
                    FastSPWebThreadWorkerQueue.GlobalSPWebThreadWorkerQueue.ListsCacheDictionary.Add(HashKey, SPListsCacheCollectionObject);
            }
        }
    }
}